// createWebHistory
import {createRouter,createWebHashHistory} from 'vue-router';

import Login from "../layouts/Login.vue";
import Index from "../layouts/Index.vue";

import Home from "../views/home/Home.vue";
import List from "../views/list/List.vue";
import Cart from "../views/cart/Cart.vue";
import Info from "../views/user/Info.vue";
//路由
let routes = [
    {
        path: "/",
        redirect: '/home/home'
    },
    { path: "/login", name: "login",meta:{title:"登录",top:"0"},component: Login,
    },
    /*{ path: "/home", name: "home",meta:{title:"个人页",top:"0"},component: Home,
    },
    { path: "/index", name: "home",meta:{title:"个人页",top:"0"},component: Index,
    },*/
    { path: "/home", component: Index,meta:{title:"首页"},
        redirect: '/home/home',
        children: [
            { path: 'home', name: "home",meta:{title:"首页",top:"home"}, component: Home },
            //{ path: 'goodsadd', name: "goodsadd",meta:{title:"添加商品",top:"1"}, component: GoodsAdd },
        ]
    },
    { path: "/list", component: Index,meta:{title:"分类"},
        redirect: '/list/list',
        children: [
            { path: 'list', name: "list",meta:{title:"分类",top:"list"}, component: List },
            //{ path: 'goodsadd', name: "goodsadd",meta:{title:"添加商品",top:"1"}, component: GoodsAdd },
        ]
    },
    { path: "/cart", component: Index,meta:{title:"分类"},
        redirect: '/cart/cart',
        children: [
            { path: 'cart', name: "cart",meta:{title:"购物车",top:"cart"}, component: Cart },
            //{ path: 'goodsadd', name: "goodsadd",meta:{title:"添加商品",top:"1"}, component: GoodsAdd },
        ]
    },
    { path: "/user", component: Index,meta:{title:"用户"},
        redirect: '/user/info',
        children: [
            { path: 'info', name: "info",meta:{title:"用户中心",top:"user"}, component: Info },
            //{ path: 'goodsadd', name: "goodsadd",meta:{title:"添加商品",top:"1"}, component: GoodsAdd },
        ]
    },
]

// Vue-router新版本中，需要使用createRouter来创建路由
export default  createRouter({
    // 指定路由的模式,此处使用的是hash模式
    history: createWebHashHistory(),
    //history: createWebHistory(process.env.BASE_URL),
    routes
})